Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Filter by Rating Block > Display a notice in the editor if the store has no products with ratings #7763

Merged
merged 9 commits into from
Dec 12, 2022

Conversation

nefeline
Copy link
Contributor

@nefeline nefeline commented Nov 28, 2022

Fixes #7735

This PR ensures a notice is displayed in the editor whenever the Filter by Rating block is used in a store that has no products with ratings.

Additionally, per @vivialice's recommendation, we are now allowing users to preview/update the content, settings, and color for the filter even when the store doesn't have any ratings yet:

Before After
Screenshot 2022-11-28 at 09 22 36 Screenshot 2022-12-08 at 12 55 11

User Facing Testing

  1. Make sure your store doesn't have any products with ratings.
  2. Open the editor and add a Filter by Rating block.
  3. Make sure a notice is displayed informing there are no products with ratings available, as demonstrated on the screenshot shared here on this PR. Also, ensure the dummy list with default product ratings is displayed below the notice.
  4. Now, add a rating to any product in your store.
  5. Refresh the editor and make sure the notice is replaced with the expected value:

Screenshot 2022-11-28 at 09 41 39

  1. On the front end, ensure the filter by rating works as expected and without any changes.

WooCommerce Visibility

  • WooCommerce Core
  • Feature plugin
  • Experimental

Changelog

A notice is now displayed in the editor whenever the Filter by Rating block is used in a store that has no products with ratings. Additionally, users can now preview/update the content, settings, and color for the filter even when the store doesn't have any ratings yet.

@github-actions
Copy link
Contributor

The release ZIP for this PR is accessible via:

https://wcblocks.wpcomstaging.com/wp-content/uploads/woocommerce-gutenberg-products-block-7763.zip

@github-actions
Copy link
Contributor

github-actions bot commented Nov 28, 2022

Script Dependencies Report

The compare-assets action has detected some changed script dependencies between this branch and trunk. Please review and confirm the following are correct before merging.

Script Handle Added Removed
rating-filter.js wp-compose, wp-deprecated, wp-dom, wp-warning ⚠️

This comment was automatically generated by the ./github/compare-assets action.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 28, 2022

TypeScript Errors Report

Files with errors: 431
Total errors: 2064

⚠️ ⚠️ This PR introduces new TS errors on 1 files:

assets/js/blocks/rating-filter/block.tsx

@github-actions
Copy link
Contributor

github-actions bot commented Nov 28, 2022

Size Change: +7.87 kB (+1%)

Total Size: 983 kB

Filename Size Change
build/active-filters-frontend.js 7.74 kB +1 B (0%)
build/active-filters-wrapper-frontend.js 6.01 kB -1 B (0%)
build/active-filters.js 7.32 kB +1 B (0%)
build/all-products-frontend.js 11.3 kB -2 B (0%)
build/all-products.js 33.2 kB -1 B (0%)
build/attribute-filter-frontend.js 22.6 kB -13 B (0%)
build/attribute-filter-wrapper-frontend.js 7.17 kB -9 B (0%)
build/attribute-filter.js 12.3 kB +5 B (0%)
build/cart-blocks/cart-cross-sells-products--product-add-to-cart-frontend.js 5.48 kB +3 B (0%)
build/cart-blocks/cart-cross-sells-products-frontend.js 4.77 kB -2 B (0%)
build/cart-blocks/cart-express-payment--checkout-blocks/express-payment-frontend.js 5.04 kB +1 B (0%)
build/cart-blocks/cart-express-payment-frontend.js 779 B +1 B (0%)
build/cart-blocks/cart-line-items--mini-cart-contents-block/products-table-frontend.js 5.29 kB -2 B (0%)
build/cart-blocks/cart-line-items-frontend.js 1.07 kB +1 B (0%)
build/cart-blocks/cart-order-summary-frontend.js 1.23 kB -3 B (0%)
build/cart-blocks/filled-cart-frontend.js 783 B +1 B (0%)
build/cart-blocks/order-summary-coupon-form-frontend.js 1.72 kB -1 B (0%)
build/cart-blocks/order-summary-discount-frontend.js 2.16 kB +4 B (0%)
build/cart-blocks/order-summary-shipping-frontend.js 5.99 kB -1 B (0%)
build/cart-blocks/proceed-to-checkout-frontend.js 1.19 kB -1 B (0%)
build/cart-frontend.js 46.3 kB +96 B (0%)
build/cart.js 46.4 kB +1 B (0%)
build/checkout-blocks/actions-frontend.js 1.77 kB +3 B (0%)
build/checkout-blocks/billing-address-frontend.js 1.09 kB -1 B (0%)
build/checkout-blocks/contact-information-frontend.js 1.86 kB -3 B (0%)
build/checkout-blocks/express-payment-frontend.js 1.13 kB -2 B (0%)
build/checkout-blocks/order-note-frontend.js 1.14 kB -1 B (0%)
build/checkout-blocks/order-summary-cart-items-frontend.js 3.67 kB +3 B (0%)
build/checkout-blocks/order-summary-coupon-form-frontend.js 1.89 kB -1 B (0%)
build/checkout-blocks/order-summary-discount-frontend.js 2.28 kB +2 B (0%)
build/checkout-blocks/order-summary-frontend.js 1.24 kB -1 B (0%)
build/checkout-blocks/order-summary-taxes-frontend.js 435 B -1 B (0%)
build/checkout-blocks/payment-frontend.js 8.31 kB -5 B (0%)
build/checkout-blocks/shipping-address-frontend.js 1.07 kB -1 B (0%)
build/checkout-blocks/shipping-methods-frontend.js 5.01 kB +5 B (0%)
build/checkout-blocks/terms-frontend.js 1.63 kB -4 B (0%)
build/checkout-frontend.js 48.4 kB +104 B (0%)
build/checkout.js 40.6 kB +2 B (0%)
build/filter-wrapper-frontend.js 13.8 kB +24 B (0%)
build/handpicked-products.js 7.29 kB -1 B (0%)
build/mini-cart-contents-block/footer-frontend.js 2.95 kB -2 B (0%)
build/mini-cart-contents-block/products-table-frontend.js 590 B -1 B (0%)
build/mini-cart-contents-block/title-frontend.js 367 B -1 B (0%)
build/mini-cart-contents.js 17.1 kB +2 B (0%)
build/mini-cart-frontend.js 1.88 kB +1 B (0%)
build/mini-cart.js 4.29 kB -2 B (0%)
build/price-filter-frontend.js 13.6 kB -4 B (0%)
build/price-filter-wrapper-frontend.js 7.01 kB -5 B (0%)
build/price-filter.js 8.39 kB +2 B (0%)
build/product-add-to-cart-frontend.js 1.46 kB -1 B (0%)
build/product-button-frontend.js 2.17 kB -1 B (0%)
build/product-image-frontend.js 2.16 kB -2 B (0%)
build/product-price-frontend.js 2.17 kB +1 B (0%)
build/product-rating-frontend.js 1.48 kB -2 B (0%)
build/product-sale-badge-frontend.js 1.39 kB -1 B (0%)
build/product-stock-indicator-frontend.js 1.26 kB -1 B (0%)
build/product-summary-frontend.js 1.52 kB -2 B (0%)
build/product-tag.js 8 kB -1 B (0%)
build/product-title-frontend.js 1.58 kB +1 B (0%)
build/product-title.js 3.3 kB -1 B (0%)
build/rating-filter-frontend.js 14.1 kB +6.92 kB (+97%) 🆘
build/rating-filter-wrapper-frontend.js 6.03 kB +624 B (+12%) ⚠️
build/rating-filter.js 5.98 kB +179 B (+3%)
build/reviews-frontend.js 7.02 kB -3 B (0%)
build/single-product-frontend.js 17.5 kB -27 B (0%)
build/single-product.js 10.1 kB -3 B (0%)
build/stock-filter-frontend.js 7.79 kB -3 B (0%)
build/stock-filter-wrapper-frontend.js 6.04 kB -2 B (0%)
build/stock-filter.js 6.71 kB +1 B (0%)
build/vendors--attribute-filter-wrapper--mini-cart-contents-block/footer--product-add-to-cart-frontend.js 0 B -6.86 kB (removed) 🏆
build/vendors--attribute-filter-wrapper-frontend.js 8.21 kB +10 B (0%)
build/vendors--cart-blocks/cart-cross-sells-products--cart-blocks/order-summary-shipping--checkout-blocks--18f9376a-frontend.js 19.1 kB +2 B (0%)
build/vendors--cart-blocks/cart-cross-sells-products--product-add-to-cart-frontend.js 7.53 kB -3 B (0%)
build/vendors--cart-blocks/order-summary-shipping--checkout-blocks/order-summary-shipping--checkout-block--dda5866c-frontend.js 8.85 kB -2 B (0%)
build/wc-blocks-vendors.js 62.4 kB -2 B (0%)
build/vendors--attribute-filter-wrapper--mini-cart-contents-block/footer--product-add-to-cart--rating-fil--b47816ec-frontend.js 6.86 kB +6.86 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size
build/all-reviews.js 7.79 kB
build/blocks-checkout.js 27.3 kB
build/cart-blocks/cart-accepted-payment-methods-frontend.js 1.38 kB
build/cart-blocks/cart-cross-sells-frontend.js 253 B
build/cart-blocks/cart-items-frontend.js 299 B
build/cart-blocks/cart-totals-frontend.js 319 B
build/cart-blocks/empty-cart-frontend.js 346 B
build/cart-blocks/order-summary-fee-frontend.js 273 B
build/cart-blocks/order-summary-heading-frontend.js 455 B
build/cart-blocks/order-summary-subtotal-frontend.js 274 B
build/cart-blocks/order-summary-taxes-frontend.js 435 B
build/checkout-blocks/billing-address--checkout-blocks/shipping-address-frontend.js 3.9 kB
build/checkout-blocks/fields-frontend.js 343 B
build/checkout-blocks/order-summary-fee-frontend.js 276 B
build/checkout-blocks/order-summary-shipping-frontend.js 6.04 kB
build/checkout-blocks/order-summary-subtotal-frontend.js 273 B
build/checkout-blocks/totals-frontend.js 325 B
build/featured-category.js 13.2 kB
build/featured-product.js 13.4 kB
build/filter-wrapper.js 2.4 kB
build/general-style-rtl.css 1.29 kB
build/general-style.css 1.29 kB
build/legacy-template.js 2.86 kB
build/mini-cart-component-frontend.js 20 kB
build/mini-cart-contents-block/empty-cart-frontend.js 366 B
build/mini-cart-contents-block/filled-cart-frontend.js 230 B
build/mini-cart-contents-block/items-frontend.js 237 B
build/mini-cart-contents-block/shopping-button-frontend.js 288 B
build/price-format.js 1.19 kB
build/product-add-to-cart--product-button--product-category-list--product-image--product-price--product-r--a0326d00.js 226 B
build/product-add-to-cart--product-button--product-image--product-rating--product-title.js 151 B
build/product-add-to-cart.js 8.37 kB
build/product-best-sellers.js 7.62 kB
build/product-button--product-category-list--product-image--product-price--product-rating--product-sale-b--e17c7c01.js 438 B
build/product-button--product-image--product-rating--product-sale-badge--product-title.js 301 B
build/product-button.js 3.85 kB
build/product-categories.js 2.36 kB
build/product-category-list-frontend.js 1.14 kB
build/product-category-list.js 503 B
build/product-category.js 8.61 kB
build/product-image.js 3.93 kB
build/product-new.js 7.62 kB
build/product-on-sale.js 7.95 kB
build/product-price.js 1.54 kB
build/product-query.js 5.91 kB
build/product-rating.js 816 B
build/product-sale-badge.js 811 B
build/product-search.js 2.61 kB
build/product-sku-frontend.js 629 B
build/product-sku.js 377 B
build/product-stock-indicator.js 644 B
build/product-summary.js 920 B
build/product-tag-list-frontend.js 1.13 kB
build/product-tag-list.js 497 B
build/product-top-rated.js 7.86 kB
build/products-by-attribute.js 8.54 kB
build/reviews-by-category.js 11.2 kB
build/reviews-by-product.js 12.3 kB
build/vendors--cart-blocks/cart-cross-sells-products--cart-blocks/cart-line-items--cart-blocks/cart-order--671ca56f-frontend.js 5.26 kB
build/vendors--cart-blocks/cart-line-items--checkout-blocks/order-summary-cart-items--mini-cart-contents---233ab542-frontend.js 3.14 kB
build/vendors--cart-blocks/order-summary-shipping--checkout-blocks/billing-address--checkout-blocks/order--5b8feb0b-frontend.js 4.85 kB
build/wc-blocks-data.js 18.8 kB
build/wc-blocks-editor-style-rtl.css 5.22 kB
build/wc-blocks-editor-style.css 5.23 kB
build/wc-blocks-google-analytics.js 1.56 kB
build/wc-blocks-middleware.js 934 B
build/wc-blocks-registry.js 2.92 kB
build/wc-blocks-shared-context.js 1.52 kB
build/wc-blocks-shared-hocs.js 1.72 kB
build/wc-blocks-style-rtl.css 24.2 kB
build/wc-blocks-style.css 24.2 kB
build/wc-blocks-vendors-style-rtl.css 1.95 kB
build/wc-blocks-vendors-style.css 1.95 kB
build/wc-blocks.js 2.63 kB
build/wc-payment-method-bacs.js 816 B
build/wc-payment-method-cheque.js 811 B
build/wc-payment-method-cod.js 909 B
build/wc-payment-method-paypal.js 837 B
build/wc-settings.js 2.6 kB

compressed-size-action

@nefeline nefeline marked this pull request as ready for review November 30, 2022 19:32
@rubikuserbot rubikuserbot requested review from a team and danieldudzic and removed request for a team November 30, 2022 19:33
@nefeline
Copy link
Contributor Author

Hey @vivialice! Would you please give feedback regarding the copy used here? "There are no products with ratings." is the one currently in use. Thanks!

@nefeline
Copy link
Contributor Author

A note about e2e tests: while working on this issue, I noticed all e2e tests for the filter by rating block (among others) are temporarily disabled ( ref. #7744 ). For now, I'm not adding any tests to cover this new notice, but opening a separate issue to do so as soon as the tests are up and running again.

@nefeline nefeline requested a review from dinhtungdu November 30, 2022 19:46
@nefeline nefeline added type: bug The issue/PR concerns a confirmed bug. block: filter by rating Issues related to the Filter by Rating block. status: needs review labels Nov 30, 2022
Copy link
Member

@dinhtungdu dinhtungdu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for the PR! It's testing well on my end 🎉 . I left a couple of suggestions but otherwise, this is LGTM.

assets/js/blocks/rating-filter/block.tsx Outdated Show resolved Hide resolved
<Notice status="warning" isDismissible={ false }>
<p>
{ __(
'There are no products with ratings.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can be more explicit to merchants here by mentioning that the block won't display on the front end until their store has reviews.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a good call: in fact, I believe we could be more explicit about this on other blocks as well, such as the Filter Attributes. Already tagged @vivialice here earlier: looking forward to hearing her thoughts about this copy.

@vivialice
Copy link

Hey @nefeline ! Thanks for tagging me in this. I agree with @dinhtungdu, the store not currently having reviews doesn't mean they should feel like they should remove the block so I have a suggestion for improved copy:

Your store doesn't have any products with ratings yet. This filter option will display when a product receives a review.

Additionally, even if the store doesn't have any ratings I don't think we should hide the UI from them. I think we should display the notice and an example for the rating checklist as default. Right now there aren't styling settings available but eventually the user should be able to define these even if their store doesn't have ratings. (eg scenario - brand new store.)

@nefeline
Copy link
Contributor Author

nefeline commented Dec 5, 2022

Thanks @vivialice !

Additionally, even if the store doesn't have any ratings I don't think we should hide the UI from them. I think we should display the notice and an example for the rating checklist as default.

Great call! Just to confirm that we are on the same page, is the following screenshot a correct representation of what you are envisioning here, allowing users to preview/update the content, settings, and color for the filter even when the store doesn't have any ratings yet?

Screenshot 2022-12-05 at 17 55 47

@vivialice
Copy link

Yes, that's correct 👍

Just to check, is the vertical spacing between each filter option the same as the other lists?

And I just noticed another thing! The block name should just be Filter by Rating. And the description should be Enable customers to filter products by their rating. (as we aren't using the word "grid" to describe multi-product layouts anymore)

@nefeline
Copy link
Contributor Author

nefeline commented Dec 8, 2022

Yes, that's correct 👍

Awesome, thanks for confirming! The component was updated to match this new scope. Additionally, the PR description and testing instructions were updated to match the expected design.

Just to check, is the vertical spacing between each filter option the same as the other lists?

It looks like we have an extra margin-bottom just for the .wc-block-components-product-rating, so when comparing this component with others, such as the filter by attribute block, the spacing differs. If I remove the margin-bottom we end up with something like this:

Before After
Screenshot 2022-12-08 at 13 50 06 Screenshot 2022-12-08 at 13 49 48

Let me know what you think should be the new default here then I'll go ahead and update it ;)

And I just noticed another thing! The block name should just be Filter by Rating. And the description should be Enable customers to filter products by their rating. (as we aren't using the word "grid" to describe multi-product layouts anymore)

Good call! I'm going ahead and opening a separate PR for this since this one is focusing on the notice.

Copy link
Member

@dinhtungdu dinhtungdu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @nefeline, the PR is testing well on my end, thanks for your updates! I have some questions about code reuse, please see the review comments for more details.

assets/js/blocks/rating-filter/preview.tsx Outdated Show resolved Hide resolved
assets/js/blocks/rating-filter/block.tsx Outdated Show resolved Hide resolved
assets/js/blocks/rating-filter/block.tsx Outdated Show resolved Hide resolved
@nefeline
Copy link
Contributor Author

the PR is testing well on my end, thanks for your updates! I have some questions about code reuse, please see the review comments for more details.

Thanks for the review @dinhtungdu 🙌 ! I initially kept preview mode x editorPreview mode separated in case we wanted to display different content on both, but considering they don't differ atm, I went ahead and adopted the consolidated approach as suggested.

Copy link
Member

@dinhtungdu dinhtungdu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for your great updates! This is LGTM! 🚀

@github-actions
Copy link
Contributor

The release ZIP for this PR is accessible via:

https://wcblocks.wpcomstaging.com/wp-content/uploads/woocommerce-gutenberg-products-block-7763.zip

@nefeline
Copy link
Contributor Author

Thanks again @dinhtungdu 🎉 !

Regarding the vertical spacing between each filter option previously discussed here: @vivialice please let me know what you think. IMO, it makes sense for us to ditch the pre-existing margin-bottom for this block and ensure spacing is consistent with other lists: depending on our decision I'll go ahead and open a separate PR to update it if needed 👍 .

@nefeline nefeline merged commit 2e0f894 into trunk Dec 12, 2022
@nefeline nefeline deleted the fix/filter-by-rating-add-no-products-notice branch December 12, 2022 21:53
@alexflorisca alexflorisca added this to the 9.2.0 milestone Dec 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: filter by rating Issues related to the Filter by Rating block. type: bug The issue/PR concerns a confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Filter by Rating block should show a notice in the editor if the store has no products with ratings
4 participants